<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Document</title>
  </head>
  <body>
    <script>
      // 方式1
      window.onload = function () {
        console.log('onload');
      };
      // 方式2
      window.addEventListener('load', function () {
        console.log('load');
      });
    </script>
  </body>
</html>